<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.text.DateFormat"%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>

<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path;
	DateFormat dfday = new SimpleDateFormat("yyyy-MM-dd");
	DateFormat dfmonth = new SimpleDateFormat("yyyy-MM");
	DateFormat dfyear = new SimpleDateFormat("yyyy");
	
	String today = dfday.format(new Date());
	
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
	<title>${headerTitle}</title>
	<base href="<%=basePath%>/" />
	
	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
  	<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1";/><!-- IE的渲染模式 -->
  	<meta name="renderer" content="webkit"><!-- 浏览器高速模式 -->
  	
  	
	<meta name="keywords"
		content="信帧,teleframe,iparking,I停车,爱停车,blackshadowwalker" />
	<meta name="description"
		content="信帧,teleframe,iparking,I停车,爱停车,blackshadowwalker" />
	<meta name="author" content="blackshadowwalker" />
	
	<link href="css/common.css" rel="stylesheet" />
	
    <link href="bootstrap/3.2/css/bootstrap.min.css" rel="stylesheet" />
	<link href="plugins/bootstrap-datetimepicker-master/css/bootstrap-datetimepicker.min.css" rel="stylesheet" />
	
	<script type="text/javascript" src="scripts/jquery/jquery-1.7.min.js" ></script>	
	<script src="bootstrap/3.2/js/bootstrap.min.js"></script>
	
	<script type="text/javascript" src="plugins/bootstrap-datetimepicker-master/js/bootstrap-datetimepicker.js"  ></script>
	<script type="text/javascript" src="plugins/bootstrap-datetimepicker-master/js/locales/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>
	
	<script type="text/javascript" src="plugins/highcharts/highcharts.js" charset="utf-8"></script>
	<script type="text/javascript" src="plugins/highcharts/exporting.js" charset="utf-8"></script>
	
	<script src="index/js/index.js" type="text/javascript"></script>
	<script src="scripts/waittool.js" type="text/javascript"></script>
	<script src="scripts/formattool.js" type="text/javascript"></script>

	<script type="text/javascript">
		var msg = "${msg}";
		if(msg!="")
			alert(msg);
		
	</script>

	<style>
		body {
			margin-left: 10px;
			margin-top: 7px;
		}
		div.highcharts-container{
			diaplay:inline;
		}
		div.map>div.submap{
			margin-right:50px;
			diaplay:inline;
		}
		
	</style>

</head>
<body>
	
	<div class="tab">
		<ul class="nav nav-tabs" name="nav-tabs" role="tablist">
			<li type="byday" ><a href="javascript:void(0);">按天查询</a></li>
			<li type="bymonth" class="active" > <a href="javascript:void(0);">按月查询</a></li>
			<li type="byyear" > <a href="javascript:void(0);">按年查询</a></li>
			<li type="byweek" > <a href="javascript:void(0);">按周查询</a></li>
			<li type="bypark" class="hidden" > <a href="javascript:void(0);">按停车场查询</a></li>
		</ul>
	</div>
	
	<br/>
	
	<div class="container">
		<div class="row" type="byday" style="display:none;" title1="按天查询">
			<center>
				<div class="print hidden"><h2>按天查询收支统计</></div>
			</center>
			<center class="notprint">
				<input type="text" id="toadytime" class="btn btn-success datetimepicker" size="16" type="text" value="<%=today %>" readonly  />	
				<input type="button" class="btn btn-info" stattype="day" for="toadytime" callback="callbackByDay" value="查询" />
				<button class="hidden-xs btn btn-primary btn-print" style="float:right;margin-right:80px;" >打印</button>
			</center>
			<div class="map print">
				<div class="submap" name="map1"></div>
				<hr/>
				<div class="submap" name="map2"></div>
			</div>
		</div>
		
		<div class="row" type="bymonth" style="display:none;" title1="按月查询">
			<center>
				<div class="print hidden"><h2>按月查询收支统计</h2></div>
			</center>
			<center class="notprint">
				<input type="text" id="monthtime" class="btn btn-success" size="16" type="text" value="<%=today.substring(0,7) %>" readonly  />
				<input type="button" class="btn btn-info" stattype="month" for="monthtime" callback="callbackByMonth"  value="查询" />
				<button class="hidden-xs btn btn-primary btn-print" style="float:right" >打印</button>
			</center>
			<div class="map print">
				<div class="submap" name="map1"></div>
				<hr/>
				<div class="submap" name="map2"></div>
				<hr/>
				<div class="submap" name="map3"></div>
			</div>
		</div>
		
		<div class="row" type="byyear" style="display:none;" title1="按年查询" >
			<center>
				<div class="print hidden"><h2>按年查询收支统计</h2></div>
			</center>
			<center class="notprint">
				<input type="text" id="yeartime" class="btn btn-success" size="16" type="text" value="<%=today.substring(0,4) %>" readonly  />
				<input type="button" class="btn btn-info"  stattype="year" for="yeartime" callback="callbackByYear" value="查询" />
				<button class="hidden-xs btn btn-primary btn-print" style="float:right" >打印</button>
			</center>
			<div class="map print">
				<div class="submap" name="map1"></div>
				<hr/>
				<div class="submap" name="map2"></div>
				<hr/>
				<div class="submap" name="map3"></div>
			</div>
		</div>
		
		<div class="row" type="byweek" style="display:none;" title1="按周查询" >
			<center>
				<div class="print hidden"><h2>按周查询收支统计</h2></div>
			</center>
			<center class="notprint">
				<input type="text" id="weektime" class="btn btn-success" size="16" type="text" value="<%=today %>" readonly  />	
				<input type="button" class="btn btn-info" stattype="week" for="weektime" callback="callbackByWeek"  value="查询" />
				<button class="hidden-xs btn btn-primary btn-print" style="float:right" >打印</button>
			</center>
			<div class="map print">
				<div class="submap" name="map1"></div>
				<hr/>
				<div class="submap" name="map2"></div>
				<hr/>
				<div class="submap" name="map3"></div>
			</div>
		</div>
		<div class="row" type="bypark" style="display:none;" title1="按停车场查询" >
			<center>
				<div class="print hidden"><h2>按停车场查询收支统计</h2></div>
			</center>
			<center class="notprint">
				<select class="form-control " style="display:inline-block;width:150px;">
					<option>.......</option>
				</select>
				<input type="text" id="parktime" class="btn btn-success" size="16" type="text" value="<%=today %>" readonly  />	
				<input type="button" class="btn btn-info" stattype="park" for="parktime" callback="callbackByPark"  value="查询" />
				<button class="btn btn-primary btn-print" style="float:right" >打印</button>
			</center>
			<div class="map print">
				<div class="submap" name="map1"></div>
				<hr/>
			</div>
		</div>
		
	</div>
	<div id="botter" class="botter">
		<br/>
		<br/>
		<br/>
	</div>
	<div id="errorFiled" style="display:none;">
	
	</div>
	
	<script src="modules/statistics/mypaystat/js/mypaystat.js" type="text/javascript" charset="utf-8" ></script>
	
	<script >
	
		//print
		$(".btn-print").click(function() {
			$(".nav-tabs").hide();
			$(".notprint").hide();
			$("#errorFiled").hide();
			var titleObj = $(this).parent().parent().find(".print&.hidden") ;
			titleObj.removeClass("hidden");
			titleObj.show();
			window.print();
			$(".nav-tabs").show();
			$(".notprint").show();
			titleObj.addClass("hidden");
			$(".print&.hidden").hide();
			$("#errorFiled").show();
		});
		
				
		$("div.container>div.row input[type='button']").click(function(){
			var stattype = $(this).attr("stattype");
			var stattypefor = $(this).attr("for");
			var callbackMap = $(this).attr("callback");
			var target = $(this).parent().parent();
			var datetime = $("#"+stattypefor).val();
			if(window.console){
				console.log("stattype="+stattype+" stattypefor="+stattypefor);
			}
			var data={
					stattype: stattype,
					datetime: datetime
				};
		 
			startMask();//等待提示开启
		
			$.ajax({
				type: 'POST',
				url: "MyPayStatisticsAction?method=query&querytype=json",
				data: data,
				success: function(retdata){
					
					endMask();//等待提示关闭
					
					console.log(retdata);
					
					if(retdata.error==-100){
						alert( retdata.msg );
						window.top.location = retdata.url;
					}else{
						if(retdata.error==0){
							window[callbackMap]( target, retdata, datetime );//按天统计
						}else{
							alert( retdata.msg );
						}
					}
			  	},
				dataType: "json",
				error : function(XMLHttpRequest, textStatus, errorThrown){
					alert( XMLHttpRequest.responseText);
					endMask();//等待提示关闭
					$("#errorFiled").html( XMLHttpRequest.responseText );
					$("#errorFiled").show();
				}
			});
		
		});
				

		$(document).ready(function() {

			var tab = $("div.tab>ul.nav-tabs>li.active");
			if (typeof (tab) != "undefined") {
				switchtab(tab.attr("type"));
			}
			//	$("div.container>div.row").show();

			$("#toadytime").datetimepicker({
				format : "yyyy-mm-dd",
				language : "zh-CN",
				weekStart : 1,
				startView : 2, //日期时间选择器打开之后首先显示的视图。 Number, String. 默认值：2, 'month'
				todayBtn : true,
				autoclose : true,
				minView : 2
			//日期时间选择器所能够提供的最精确的时间选择视图,Number, String. 默认值：0, 'hour'
			});

			$("#weektime").datetimepicker({
				format : "yyyy-mm-dd",
				language : "zh-CN",
				weekStart : 1,
				startView : 2, //日期时间选择器打开之后首先显示的视图。 Number, String. 默认值：2, 'month'
				todayBtn : true,
				autoclose : true,
				minView : 2
			//日期时间选择器所能够提供的最精确的时间选择视图,Number, String. 默认值：0, 'hour'
			});

			$("#monthtime").datetimepicker({
				format : "yyyy-mm",
				language : "zh-CN",
				weekStart : 1,
				startView : 3, //日期时间选择器打开之后首先显示的视图。 Number, String. 默认值：2, 'month'
				todayBtn : true,
				autoclose : true,
				minView : 3
			//日期时间选择器所能够提供的最精确的时间选择视图,Number, String. 默认值：0, 'hour'
			});

			$("#yeartime").datetimepicker({
				format : "yyyy",
				language : "zh-CN",
				weekStart : 1,
				startView : 4, //日期时间选择器打开之后首先显示的视图。 Number, String. 默认值：2, 'month'
				todayBtn : true,
				autoclose : true,
				minView : 4
			//日期时间选择器所能够提供的最精确的时间选择视图,Number, String. 默认值：0, 'hour'
			});

			//
			Highcharts.setOptions({
				lang : {
					contextButtonTitle : '导出',
					printChart : '打印',
					downloadJPEG : '导出为JPEG',
					downloadPDF : '导出为PDF',
					downloadPNG : '导出为PNG',
					downloadSVG : '导出为SVG'
				}
			});

		});
	</script>
	
</body>
</html>
